<template>
  <div>
    <van-swipe :autoplay="3000">
      <van-swipe-item v-for="item in banners" :key="item">
        <img class="img w100" v-lazy="item" />
      </van-swipe-item>
    </van-swipe>
  </div>
</template>

<script>
// import { getBanners } from "@api/product.js";
import { get } from "@/request/index";
export default {
  data() {
    return {
      banners: [],
    };
  },
  created() {
    this.getBanners();
  },
  methods: {
    getBanners() {
      get("/product/getBanners")
        .then((res) => (this.banners = res.banners))
        .catch((err) => console.log("获取轮播图失败", err));
      // getBanners()
      //   .then((res) => {
      //     // console.log(res.banners);
      //     this.banners = res.banners;
      //   })
      //   .catch((err) => {
      //     console.log(err);
      //   });
    },
  },
};
</script>

<style scoped>
/* .my-swipe .van-swipe-item {
  width: 100%;
}
.my-swipe .van-swipe-item .img {
  width: 100%;
} */
</style>